<?

$header = new SectionTemplate;
$header->file = "header.php";
$footer = new SectionTemplate;
$footer->file = "footer.php";

include_class('band_news');
include_class('band_members');
include_class('shows');
include_class('band_information');

$bn = new BandNewsList;
$view = 'overview';
$linkBrowse = "news.php?browse=1";
$linkLatest = "news.php";

$paging = new SectionTemplate;
$paging->file = "paging.php";
$paging->args['perPage'] = (is_numeric($_GET['e'])) ? $_GET['e'] : 10;
$paging->args['start'] = (is_numeric($_GET['s'])) ? $_GET['s'] : $paging->args['start'] = 1;

if ($_GET['id']) { 
	$view = 'detail';
	$bnd = BandNews::get($_GET['id']);
	$st = new SectionTemplate;
	$st->file = "news_detail.php";
	$st->args['news'] = $bnd;
} else if ($_GET['browse']) {
	$view = 'browse';
	$news = array();
	$result = $bn->get_band_news($_GET['e'], $_GET['s'], 1);
	$paging->args['total'] = $bn->get_total(1);
	$paging->args['url'] = (USE_MOD_REWRITE) ? SITE_WEB_DIRECTORY . 'news/browse/' : 'news.php';
	foreach($result as $bnd) {
		$st = new SectionTemplate;
		$st->file = "news_summary.php";
		$st->args['news'] = $bnd;
		$news[] = $st;
	}
	
} else if ($_GET['q']) {
	$view = 'search';	
	$paging->args['total'] = $bn->get_total_search($_GET['q'], 1);
	if (USE_MOD_REWRITE) {
		$paging->args['url'] = SITE_WEB_DIRECTORY . '/news/search/' . $_GET['q'] . '/';
	} else {
		$paging->args['url'] = SITE_WEB_DIRECTORY . '/news.php?q=' . $_GET['q'];
	}
	$news = array();
	$result = $bn->get_band_news_search($_GET['q'], $_GET['e'], $_GET['s'], 1);
	foreach($result as $bnd) {
		$st = new SectionTemplate;
		$st->file = "news_summary.php";
		$st->args['news'] = $bnd;
		$news[] = $st;
	}
} else {
	$result = $bn->get_band_news(5, null, 1);
	$news = array();
	foreach($result as $bnd) {
		$ln = new SectionTemplate;
		$ln->file = "news_summary.php";
		$ln->args['news'] = $bnd;
		$news[] = $ln;
	}
}

?>